<?php
include('../config.php');
header("Access-Control-Allow-Origin:*");

$phone = $_POST['phone'];
$sql = "select * from shop_car where phone= '$phone'";

// $res时一个资源类型
$res = mysql_query($sql);
$count=mysql_num_rows($res);


if ($count !=0) {
        $list = array();
        // 通过循环去资源里抓取数据，每取一行，都是一个$row，取完了循环也就结束了
          while ($row = mysql_fetch_assoc($res)) {
            array_push($list, $row);
          }
        // 按照接口文档返回对应的数据格式
          echo json_encode(array(
            "code" => 200,
            "body" => array(
              "list" => $list,
              "msg" => '购物车数据查询成功！'
            )
          ));

} else {
  echo json_encode(array(
    "code" => 201,
    "body" => array(
      "msg" => '您的购物车还空荡荡的哦!'
    )
    ));
}






?>